<extend name="Index/index" />
<block name="nav">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="<{:U(Index/index)}>">首页</a>
            </li>
            <li class="active">文章管理</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search" action="<{:U(Article/index)}>" method="post">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" name="title" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
                <button class="btn-sm btn-primary">搜索</button>
            </form>
        </div><!-- #nav-search -->
    </div>
</block>
<block name="nav1">
    <div class="page-content">
        <div class="page-header">
            <h1>
                文章管理
                <small>
                    <i class="icon-double-angle-right"></i>
                     查看
                </small>
            </h1>
        </div><!-- /.page-header -->
    </div>
</block>

<block name="admin">
    <div class="pull-left col-md-12">
        <h1 class="text-center">文章管理</h1>
            <!-- 分页 -->
            <div class="pull-right">
                <{$page}>
            </div>
        </div>
        <empty name="data">
            <h1 class="text-center red">暂无数据</h1>
        <else />
            <volist name="data" id="v">
                <table class="table">
                    <tr class="blue">
                        <th>ID</th>
                        <th>标题</th>
                        <th>作者</th>
                        <th>分类名</th>
                        <th>创建时间</th>
                        <th>浏览次数</th>
                        <th>点赞数</th>
                        <th>状态</th>
                    </tr>
                    <tr>
                        <td><{$v['id']}></td>
                        <td><{$v['title']}></td>
                        <td><{$v['name']}></td>
                        <td><{$v['cname']}></td>
                        <td><{$v['create_time']}></td>
                        <td><{$v['read_times']}></td>
                        <td><{$v['zan']}></td>
                        <td class="col-md-3">
                            <switch name="v['status']">
                                <case value="0">
                                    <!-- <a href="<{:U('Article/status', array('id'=>$v['id'], 'action'=>'pz'))}>" class="btn-sm btn-info">批准</a> -->
                                    <a onclick="pz(this, <{$v['id']}>)" class="btn-sm btn-info">批准</a>
                                    <a onclick="fj(this, <{$v['id']}>)" class="btn-sm btn-warning">否决</a>
                                    <!-- <a href="<{:U('Article/status', array('id'=>$v['id'], 'action'=>'fj'))}>" class="btn-sm btn-warning">否决</a> -->
                                    <a class="btn-sm btn-default">审批中...</a>
                                </case>
                                <case value="1">
                                    <a class="btn-sm btn-success">已发布</a>
                                </case>
                                <case value="2">
                                    <a class="btn-sm btn-danger">未通过</a>
                                </case>
                            </switch>
                        </td>
                    </tr>
                </table>
                <table class="table">
                    <tr class="blue">
                        <th colspan="8" class="text-center h2 col-md-12">内容</th>
                        <th class="addbtn" onclick="show(this)">+</th>
                        <th class="jianbtn" onclick="hide(this)">-</th>
                    </tr>
                    <tr>
                        <td class="article" colspan="8">
                            <{:htmlspecialchars_decode(htmlspecialchars_decode($v['content']))}>
                        </td>
                    </tr>
                </table>
                <div class="fg"></div>
            </volist>
        </empty>

        <!-- 分页 -->
        <div class="text-center">
            <hr>
            <{$page}>
        </div>
    </div>

    <!-- 模态框文章详细内容 -->
    <div id="content">
        <div id="content1">
            <h3 class="text-center h2" id="title"></h3>
            <div id="content2"></div>
        </div>
    </div>

    <script type="text/javascript">
        var url = "<{:U('Article/ajax')}>";

        function show(obj)
        {
            // console.log($(obj).parent().next().children());
            $(obj).parent().next().children().fadeTo(2000,1).slideDown(3000);
            $(obj).css('display', 'none');
            $(obj).next().css('display', 'block');
        }

        function hide(obj)
        {
            // console.log($(obj).parent().next().children());
            $(obj).parent().next().children().fadeTo(1000,0).slideUp(500);
            $(obj).prev().css('display', 'block');
            $(obj).css('display', 'none');
        }

        function pz(obj, id)
        {
            $.ajax({
                type:'get',
                url:"<{:U('Article/pzAjax')}>",
                data:'id='+id,
                dataType:'json',
                success:function(data)
                {
                    if (data == 1) {
                        $(obj).parent().html('<a class="btn-sm btn-success">已发布</a>');
                    }
                },
            })
        }


        function fj(obj, id)
        {
            $.ajax({
                type:'get',
                url:"<{:U('Article/fjAjax')}>",
                data:'id='+id,
                dataType:'json',
                success:function(data)
                {
                    if (data == 1) {
                        $(obj).parent().html('<a class="btn-sm btn-danger">未通过</a>');
                    }
                },
            })
        }
    </script>
</block>
